{include file="header.htm" /}
<body class="bodystyle" style="overflow-y: scroll; cursor: default; -moz-user-select: inherit;">
<div id="toolTipLayer" style="position: absolute; z-index: 9999; display: none; visibility: visible; left: 95px; top: 573px;"></div>
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <a class="back_xin" href='{:weapp_url("PointsShop/PointsShop/index")}' title="返回"><i class="iconfont e-fanhui"></i></a>
            <div class="subject">
                <h3>编辑积分商品</h3>
                <h5></h5>
            </div>
        </div>
    </div>

    <form class="form-horizontal" id="post_form" action="{:weapp_url('PointsShop/PointsShop/add')}" method="post">
        <div class="flexigrid htitx">
            <div class="ncap-form-default">
                <div class="hDiv">
                    <div class="hDivBox">
                        <table cellspacing="0" cellpadding="0" style="width: 100%">
                            <thead>
                                <tr>
                                    <th class="w10"><div class="tc"></div></th>
                                    <th class="w10"><div class="tc">交易设置</div></th>
                                    <th><div></div></th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                </div>

                <dl class="row">
                    <dt class="tit"><label><em>*</em>编辑商品</label></dt>
                    <dd class="opt">
                        <p class="notic2">提示：如果原商品的规格信息产生变更，对应积分商品将自动下架，必须重新编辑积分商品的积分价方可上架</p>
                        <div id="showGoods">{$showGoods}</div>
                        <input type="hidden" name="aidInput" id="aidInput" value="{$pointsGoods.aid}">
                    </dd>
                </dl>

                <dl class="row">
                    <dt class="tit"><label><em>*</em>运费设置</label></dt>
                    <dd class="opt">
                        <label class="curpoin"><input name="goods_shipping" value="1" type="radio" {eq name="$pointsGoods.goods_shipping" value="1"} checked="checked" {/eq}>读取系统设置</label>
                        &nbsp;
                        <label class="curpoin"><input name="goods_shipping" value="2" type="radio" {eq name="$pointsGoods.goods_shipping" value="2"} checked="checked" {/eq}>包邮</label>
                    </dd>
                </dl>
                
                <div class="hDiv">
                    <div class="hDivBox">
                        <table cellspacing="0" cellpadding="0" style="width: 100%">
                            <thead>
                                <tr>
                                    <th class="w10"><div class="tc"></div></th>
                                    <th class="w10"><div class="tc">商品状态</div></th>
                                    <th><div></div></th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                </div>
                <dl class="row">
                    <dt class="tit"><label><em>*</em>上架设置</label></dt>
                    <dd class="opt">
                        <label class="curpoin"><input name="goods_status" value="1" type="radio" {eq name="$pointsGoods.goods_status" value="1"} checked="checked" {/eq}>上架</label>
                        &nbsp;
                        <label class="curpoin"><input name="goods_status" value="2" type="radio" {eq name="$pointsGoods.goods_status" value="2"} checked="checked" {/eq}>下架</label>
                        <p class="notic">积分商品的下架不影响原商品的上架状态；原商品如果下架或删除，积分商品自动下架并且无法上架</p>
                    </dd>
                </dl>

                <div class="bot">
                    <a href="JavaScript:void(0);" onclick="submitGoods();" class="ncap-btn-big ncap-btn-green">保存</a>
                </div>
            </div>
        </div>
    </form>
</div>
<script type="text/javascript">
    // 关闭所有弹框
    function closeSelectGoods(clear) {
        // 关闭所有弹框
        layer.closeAll();
    }

    // 判断输入框是否为空
    function submitGoods() {
        layer_loading('正在处理');
        $.ajax({
            url : "{:weapp_url('PointsShop/PointsShop/edit', ['_ajax'=>1])}",
            data: $('#post_form').serialize(),
            type: 'post',
            dataType: 'json',
            success: function(res) {
                layer.closeAll();
                if (1 === parseInt(res.code)) {
                    layer.msg(res.msg, {time: 1500}, function() {
                        window.location.href = "{:weapp_url('PointsShop/PointsShop/index')}";
                    });
                } else {
                    layer.alert(res.msg, {title: false, closeBtn: false}, function() {
                        layer.closeAll();
                        if (res.data.id) $(res.data.id).find('a').click();
                    });
                }
            },
            error: function(e) {
                layer.closeAll();
                layer.alert(e.responseText, {title: false, closeBtn: false});
            }
        });
    }
</script>
{include file="footer.htm" /}